import Taro, { Component } from '@tarojs/taro'
import { View,Text, ScrollView } from '@tarojs/components'
import Header from '../../components/header'
import Banner from './banner/index'
import Category from './category/index'
import Product from './product/index'
import Notice from './notice/index'
import * as actions from '@actions/home'
import { connect } from '@tarojs/redux'
import { getWindowHeight } from '@utils/style'
import './home.scss'

@connect(state => state.home, { ...actions })
class Home extends Taro.Component {
    config = {
        navigationBarTitleText: "追溯平台"
    }
    state = {
        loaded: false,
        loading: false,
        lastItemId: 0,
        hasMore: true
    }
    componentDidMount() {
        Taro.showToast({
            title: '注意，初始版本',
            icon: 'none',
            duration: 1000
        })

        this.props.dispatchHomeBannerList()
        this.props.dispatchHomeProdTagList()
    }

    render() {
        const { homeBannerList, homeProdTagList } = this.props
        return (
            <View className='home'>
                <Header />
                <ScrollView
                    scrollY
                    className='home_wrap'
                    style={{ height: getWindowHeight() }}
                >
                    <Banner list={homeBannerList} />
                    <Notice />
                    <Category />
                    <Product list={homeProdTagList} />
                </ScrollView>

            </View>

        )
    }
}

export default Home